package com.example.medical.controller;

import com.example.medical.service.EquipmentPurchaseService;
import com.example.medical.domain.EquipmentPurchase;
import com.example.medical.util.AjaxResuit;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

@RestController
@RequestMapping("/api/equipment")
@Api(tags = "器械购买数据统计（0525王婕）")
public class EquipmentPurchaseController {

    @Autowired
    private EquipmentPurchaseService equipmentPurchaseService;

    // API接口：获取指定日期的器械购买数量统计
    @ApiOperation("获取指定日期的器械购买数量统计")
    @GetMapping("/purchase-count")
    public AjaxResuit getPurchaseCount(@RequestParam String purchaseDate) {
        int count = equipmentPurchaseService.getPurchaseCount(purchaseDate);
        return AjaxResuit.success(count);
    }

    // API接口：获取热门购买器械，接收limit参数指定获取的热门器械数量
    @ApiOperation("获取热门购买器械数量")
    @GetMapping("/hot-equipment")
    public List<EquipmentPurchase> getHotEquipment(@RequestParam("limit") int limit) {
        return equipmentPurchaseService.getHotEquipment(limit);
    }

}
